<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div class="searchArea">
			<form id="searchBar">
				<div class="fieldset1 clearFix">
					<div class="fieldBox">
						<div class="label">敞口金额</div>
						<div class="field">
							<input name="crAmt" id="crAmt" type="text" class="ui-textbox" value="">
						</div>
					</div>
					
					<div class="fieldBox">
						<div class="label">变更时间</div>
						<div class="field">
							  <input name="createStDate" id="createStDate" type="text" class="ui-datepicker" value="">
	                   		  <span>---</span>
	                     	  <input name="createEndDate" id="createEndDate" type="text" class="ui-datepicker" value="">
						
						</div>
					</div>
					
					
					<div class="clearFix"></div>
					<div class="btnsBox">
						<span id="searchBtn" class="sq-button sq-button-round">查询</span> 
						<span id="clear" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
					</div>
				</div>
			</form>

		</div>
		<div id="ligergrid1" class="sq-grid"></div>
	</div>
	<script type="text/javascript">
	var grid = null;
	var buOrgCd='${buOrgCd}';
	var compId='${compId}';
	$(function () {
	    $("#ligergrid1").ligerGrid({
	    	url: '<%=path%>/project/prjLnkCompCrLim/initList.do?compId='+compId,
	    	method : 'get',
	        columns: [
	            { display: '变更时间', name: 'crtTm', render:renderDate,minWidth: 140},
	            { display: '敞口金额', name: 'crAmt', minWidth: 140 , render:renderAmt,enabledSort:true},
	            { display: '变更后有效期',  minWidth: 100,
	            	render: function (rowdata, rowindex, value){
	            		var expStDt = new Date(rowdata.startDt);
	    	    		var expStDtStr = DateUtils.formatDate(expStDt, DateUtils.YYYY_MM_DD);
	            		var expEndDt = new Date(rowdata.endDt);
	    	    		var expEndDtStr = DateUtils.formatDate(expEndDt, DateUtils.YYYY_MM_DD);
			            return expStDtStr + " -- " + expEndDtStr;
	            	}	
				},
	            { display: '审核状态', name: 'audStsCdNm', minWidth: 140},
	            { display: '流程编号', name:'pNo',minWidth: 220 , isEllipsis: false, render: function (rowdata, rowindex, value){
            			var pno = rowdata.pno;
            			var audStsCd = rowdata.audStsCd;
            			var pinstId = rowdata.pinstId;
            			var dataId = rowdata.dataId;
            			if(StringUtils.isNotEmpty(pinstId)
            					&& StringUtils.isNotEmpty(audStsCd)
            					&& StringUtils.isNotEmpty(dataId)
            					&& StringUtils.isNotEmpty(pno)){
            				var h='<a href="javascript:showFlow(';
							h+="'"+pinstId+"'";
							h+=",'"+audStsCd+"'";
							h+=",'"+dataId+"'";
							h+=')">'+pno+'</a>';
            				return h;
            			}
            		}}
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        //isScroll: false,
	        fixedCellHeight: false,
	        checkbox:true,
	        rownumbers:true
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(500);
	    $("#searchBar").ligerForm();

	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         data["lnkCompNm"] = $("#lnkCompNm").val();
	         data["audStsCd"] = $("#audStsCd").val();
	       /*   data["orgCd"] = $("#orgCd").val(); */
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	
	    $("#pageloading").hide();
	
	});
	
	
	//显示流程
	function showFlow(_pInstId, _audStsCd, _businessKey){
		if(StringUtils.isEmpty(_pInstId)){
			UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
			return;
		}
		var _formUrl = "/project/prjLnkCompCrLim/toDetailPrjLnkCompCrLimPage.do?id="+_businessKey+"@@processInstanceId="+_pInstId+"@@projectId=";
		var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
		Add_navTab('tab_prj_lnk_comp_flow_'+_businessKey,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
	}
	function clearBtn(){
		  var form = new liger.get("searchBar");
		form.setData({
			crAmt:" ",
			createStDate:" ",
			createEndDate:" ",
		 });
	}
	
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	//格式化为人民币格式
	function renderAmt(rowdata, rowindex, value) {
		if(null!==value&&value!=='undefined'&&value!==""){ 
		if(typeof Number(value)=='number'){
        var h="￥" + FormatMoney((parseFloat(value/100)).toFixed(2));
        return h;
		}
		} 
    }
	
	  
</script>

</body>
</html>